
<div class="modal-dialog ">
	<div class="modal-content">
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal"
				aria-hidden="true">&times;</button>
			<h4 class="modal-title" id="myModalLabel">修改密码</h4>
		</div>
		<div class="modal-body">
		<div class="">
			<form id="form-wizard" name="form-wizard" class="form-horizontal"
				th:object="${userDto}">
				<input id="id" type="hidden" name="id" th:value="${userDto.id}"
					readonly="readonly" /> <input id="flag" type="hidden" name="flag"
					th:value="${userDto.flag}" readonly="readonly" /> <input
					id="token" type="hidden" name="token" th:value="${userDto.token}"
					readonly="readonly" /> <input id="state_val" type="hidden"
					th:value="${userDto.state}" readonly="readonly" />
				<div class="form-group">

					<label class="col-lg-3 col-sm-2 control-label">新密码</label>
					<div class="col-lg-8">
						<input class="form-control required" id="password" placeholder="请输入新密码" type="password" name="password" />
					</div>
				</div>	
				<div class="form-group">	
					<label class="col-lg-3 col-sm-2 control-label">再次输入新密码</label>
					<div class="col-lg-8">
						<input class="form-control required" id="password2" placeholder="再次输入新密码" type="password"
							name="password2" />
					</div>
				</div>
			</form>
		 </div>	
		</div>
		<div class="modal-footer">
			<button id="reset" type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
			<button id="saveButton" type="button" class="btn btn-primary">提交</button>
			<span id="tip"> </span>
		</div>
	</div>
</div>
<script th:inline="javascript">
	/*<![CDATA[*/
	$(function() {
		$("#form-wizard").bootstrapValidator({
			//	        live: 'disabled',
			message : 'This value is not valid',
			feedbackIcons : {
				valid : 'glyphicon glyphicon-ok',
				invalid : 'glyphicon glyphicon-remove',
				validating : 'glyphicon glyphicon-refresh'
			},
			fields : {
				password : {
					validators : {
						notEmpty : {
							message : '输入新密码'
						},
						stringLength : {
							min : 6,
							max : 20,
							message : '新密码长度必须6-20字符'
						}
					}
				},
				password2 : {
					validators : {
						notEmpty : {
							message : '输入新密码'
						},
						stringLength : {
							min : 6,
							max : 20,
							message : '新密码长度必须6-20字符'
						},
						 callback: { 
							 callback: function(value, validator) {  
								 var element = $("#form-wizard").data("bootstrapValidator").getFieldElements('password');
								 
								 if(value != element.val() ){
									 return {  
		                                    valid: false,  
		                                    message: '两次输入不一致'  
		                                }  
								 }
								 return true; 
							 }
						 }
					}
				},
			}
		});

		$("#saveButton").click(
				function() {
					
					var id = $("#id").val();
					var flag = $('#form-wizard').bootstrapValidator('validate')
							.data('bootstrapValidator').isValid();
					if (flag) {
						$.ajax({
							url : 'sys/user-pwd-save',
							data : {
								"id" : id,
								'password' : $("#password").val()
							},
							type : 'post',
							success : function(result) {
								layer.msg(result.message);
								
								$('#Modal').modal('hide');
							},
							error : function(jqXHR, textStatus, errorThrown) {
							}
						});

					}

				});

	});

	/*]]>*/
</script>